//
//  KPFourViewController.swift
//  KPBaseProject
//
//  Created by Kipp Dev on 2018/3/21.
//  Copyright © 2018年 Kipp. All rights reserved.
//
// swiftlint:disable empty_parentheses_with_trailing_closure

import UIKit
import Eureka

class KPFourViewController: KPFormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        prepareView()
    }

    // MARK: - 创建视图
    fileprivate func prepareView() {

        

        form +++ Section("Section1")
        <<< TextRow() { row in
            row.title = "标题"
            row.placeholder = "请输入标题"

        }
        <<< PhoneRow() {
            $0.title = "电话"
            $0.placeholder = "请输入电话"
//                $0.add(rule: RuleType)
            $0.validate()
            $0.cell.keyboardToolbar.doneBarButton.title = "呵呵哒"
        }
            +++ Section("Section2")
        <<< DateRow() {
            $0.title = "请选择日期"
            $0.dateFormatter?.dateFormat = "yyyy-MM-dd"
            $0.noValueDisplayText = "请选择时间"
            $0.tag = "date"
            let v = navigationAccessoryView
            v?.doneButton.action = #selector(test)
        }

        <<< DecimalRow() {
            $0.title = "价格"
            $0.placeholder = "请输入价格"
            $0.formatter = DecimalFormatter()
            $0.useFormatterDuringInput = true
            }.cellSetup({ cell, _ in
                cell.textField.keyboardType = .decimalPad
            })
        animateScroll = true

        let problemBtn = UIBarButtonItem.init(title: "问题反馈", style: UIBarButtonItemStyle.plain, target: self, action: #selector(problemBtnClick(btn:)))
        navigationItem.rightBarButtonItem = problemBtn
        
        let registBtn = UIBarButtonItem.init(title: "注册", style: UIBarButtonItemStyle.plain, target: self, action: #selector(registBtnClick(btn:)))
        navigationItem.leftBarButtonItem = registBtn
    }

    @objc func problemBtnClick(btn: UIButton) {
        let vc = KPMessageViewController()
        self.navigationController?.pushViewController(vc)
    }
    
    @objc func registBtnClick(btn :UIButton){
        let vc = KPRegistViewController()
        self.navigationController?.pushViewController(vc)
    }

    @objc
    func test() {
        tableView.endEditing(true)
        KPLog("ddddd")
    }
}
